/*
package com.intexh.quickandroid.helper;

import android.Manifest;
import android.content.Context;
import android.support.annotation.NonNull;

import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.intexh.quickandroid.base.MainApplication;
import com.intexh.quickandroid.utils.LogCatUtil;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.PermissionListener;
import java.util.List;

*/
/**
 * Created by Frank on 2017/12/28.
 *//*


public enum LocationHelper {
    INSTANCE;
    public void getLocation(Context context,OnLocationCalBack calBack){
        //需要获取设备权限
        AndPermission.with(context)
                .requestCode(300)
                .permission(Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION)
                .rationale((requestCode, rationale) ->
                        // 此对话框可以自定义，调用rationale.resume()就可以继续申请。
                        AndPermission.rationaleDialog(context, rationale).show()
                )
                .callback(new PermissionListener() {
                    @Override
                    public void onSucceed(int requestCode, @NonNull List<String> grantPermissions) {
                        final int[] errorCount = {0};
                        AMapLocationClient mLocationClient = new AMapLocationClient(MainApplication.getAppContext());
                        mLocationClient.setLocationListener(aMapLocation -> {
                            if (aMapLocation != null) {
                                if (aMapLocation.getErrorCode() == 0) {
                                    //定位成功后停止定位
                                    mLocationClient.stopLocation();
                                    LogCatUtil.e("frank","定位成功："+aMapLocation.getLatitude()+"-"+aMapLocation.getLongitude()+"-"+
                                            aMapLocation.getProvince()+"-"+aMapLocation.getCity()+"-"+aMapLocation.getDistrict()+"-"+aMapLocation.getAddress());
                                    calBack.onLocationSuccess(aMapLocation.getLatitude(),aMapLocation.getLongitude(),
                                            aMapLocation.getProvince(),aMapLocation.getCity(),aMapLocation.getDistrict(),aMapLocation.getAddress());
                                }else {
                                    errorCount[0]++;
                                    if(errorCount[0]>5){
                                        mLocationClient.stopLocation();
                                        calBack.onLocationFail("高德定位失败,"+aMapLocation.getErrorCode()+"-"+aMapLocation.getErrorInfo());
                                    }
                                    //定位失败时，可通过ErrCode（错误码）信息来确定失败的原因，errInfo是错误信息，详见错误码表。
                                    LogCatUtil.e("frank","高德定位失败, ErrCode:"
                                            + aMapLocation.getErrorCode() + ", errInfo:"
                                            + aMapLocation.getErrorInfo());
                                }
                            }
                        });
                        AMapLocationClientOption option = new AMapLocationClientOption();
                        option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
                        option.setOnceLocation(false);
                        option.setInterval(1000);
                        option.setNeedAddress(true);
                        //给定位客户端对象设置定位参数
                        mLocationClient.setLocationOption(option);
                        //启动定位
                        mLocationClient.startLocation();
                    }
                    @Override
                    public void onFailed(int requestCode, @NonNull List<String> deniedPermissions) {
                        calBack.onLocationFail("定位权限未授权");
                        if (AndPermission.hasAlwaysDeniedPermission(context, deniedPermissions)) {
                            AndPermission.defaultSettingDialog(context).show();
                        }
                    }
                })
                .start();
    }

    public interface OnLocationCalBack{
        void onLocationSuccess(double lat, double lng,String province,String city,String district, String msg);
        void onLocationFail(String msg);    //定位失败时会继续发起定位 间隔1秒，失败多次此方法执行多次
    }

}
*/
